﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Template/Site_Main.Master" AutoEventWireup="true"
    CodeBehind="education_account.aspx.cs" Inherits="RegisterationSystem.Space_Education.education_account" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
      <!--
        $(function () {
            //设置导航位置
            setLocalToParent();
            //初始化企业用户数据列表控件
            $("#dg").datagrid({
                idField: "id",      //标识字段,主键
                url: "../SyncService/GetDataList.ashx?action=GetEduAll",
                pagination: true,   //是否开启分页
                rownumbers: true,   //行号
                pageSize: 10,
                pageNumber: 1,
                columns: [[
                            { field: 'ck', checkbox: true, width: 150 },
                            { field: 'accountname', title: '用户名', width: 220, align: 'center' },
                            { field: 'isdisable', title: '帐号状态', width: 100, align: 'center',
                                formatter: function (value) {
                                    if (value) {
                                        return "禁用";
                                    } else {
                                        return "正常";
                                    }
                                }
                            },
                            { field: 'superaccount', title: '帐号类型', width: 100, align: 'center',
                                formatter: function (value) {
                                    if (value=="1") {
                                        return "超级账号";
                                    } else {
                                        return "普通账号";
                                    }
                                }
                            },
                            { field: 'id', title: '操作', width: 150, align: 'center', formatter: function (value, row) {
                                var strret = "";
                                if (row.isdisable == "1") {
                                    strret += "<a href='javascript:void(0)' onclick='UpdSchoolAcc(" + value + ",0);'>启用</a>&nbsp;&nbsp;";
                                } else {
                                    strret += "<a href='javascript:void(0)' onclick='UpdSchoolAcc(" + value + ",1);'>禁用</a>&nbsp;&nbsp;";
                                }
                                strret += "<a href='javascript:void(0)' onclick='DelSchoolAcc(" + value + ");'>删除</a>";
                                return strret;
                            }
                            }
                         ]]
            })
        });
        //-->

        //验证
        function submitForm() {
            //验证必填项
            if (!$("#aspnetForm").form("validate")) {
                return false;
            }
         if(1!=<%=EduSuperAccount %>)
          {
           alert("您不是超级账号,不具备该操作权限!");
           return false;
          }
            return true;
        }

        //删除教育局帐号
        function DelSchoolAccList() {
         if(1==<%=EduSuperAccount %>)
         {
            //id集合
            var ids = "";
            //获取选择集合
            var rows = $('#dg').datagrid('getSelections');
            //是否选中行
            if (rows.length == 0) {
                alert("请选择行");
                return;
            }
            var bool = true;
            //遍历选择行
            for (var i = 0; i < rows.length; i++) {
                ids += rows[i].id + ",";
                if(rows[i].id==<%=Sid %>){
                    bool=false;
                }
            }
            if(bool)
            {
            $.messager.confirm('提示', '确认删除吗？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "del", "id": ids }, function (data) {
                        $.messager.alert("消息提示", "删除成功！");
                        $('#dg').datagrid('reload');
                    });
                }
            });
            }else
            {
                alert("请取消删除自身帐号!");
                return;
            }
            }
       else
        {
         alert("您不是超级账号,不具备该操作权限!");
        }
        }
        //修改教育局用户状态
        function UpdSchoolAcc(id, status) {
       if(1==<%=EduSuperAccount %>)
        {
        if(id!=<%=Sid %>){
            $.messager.confirm('提示', '确认修改？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "upd", "id": id, "status": status }, function (data) {
                        $.messager.alert("消息提示", "修改成功！");
                        $('#dg').datagrid('reload');
                    });
                }
            });
            }else{
                alert("不能修改自身帐号!");
                return;
            }
            }
        else
        {
         alert("您不是超级账号,不具备该操作权限!");
        }
        }

        //根据ID删除教育局帐号
        function DelSchoolAcc(id) {
       if(1==<%=EduSuperAccount %>)
        {
        if(id!=<%=Sid %>){
            $.messager.confirm('提示', '确认删除？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "delacc", "id": id }, function (data) {
                        $.messager.alert("消息提示", "删除成功！");
                        $('#dg').datagrid('reload');
                    });
                }
            });
            }else{
                alert("不能删除自身帐号!");
                return;
            }
            }
       else
        {
         alert("您不是超级账号,不具备该操作权限!");
        }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Place_Local" runat="server">
    <div class="localTitle">
        <a>教育局账号管理</a>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="loadheight">
        <table width="100%%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td bgcolor="#FFFFFF">
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                </table>
                            </td>
                        </tr>
                    </table>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>教育局账号添加</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div style="margin-top: 5px">
                                </div>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td width="8%" height="20" align="right">
                                            用户名：
                                        </td>
                                        <td width="23%">
                                            <input type="text" id="txtname" style="width: 130px;" class="easyui-validatebox"
                                                runat="server" data-options="required:true" maxlength="15" />
                                        </td>
                                        <td width="9%" height="20" align="right">
                                            是否禁用：
                                        </td>
                                        <td width="60%">
                                            <select id="ddlstatus" runat="server" class="easyui-combobox" data-options="required:true,editable:false">
                                                <option value="0">否</option>
                                                <option value="1">是</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height="1">
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="8%" height="20" align="right">
                                            密 码：
                                        </td>
                                        <td>
                                            <input type="password" id="txtpwd" style="width: 130px;" class="easyui-validatebox"
                                                runat="server" data-options="required:true" maxlength="16" />
                                        </td>
                                        <td height="20" align="right">
                                        账号类型:
                                        </td>
                                        <td width="60%">
                                         <select id="EduAccountType" runat="server" class="easyui-combobox" data-options="required:true,editable:false">
                                                <option value="0">普通账号</option>
                                                <option value="1">超级账号</option>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height="1">
                                        </td>
                                        <td>
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td height="20">
                                            &nbsp;
                                        </td>
                                        <td align="right">
                                            <asp:Button ID="btnadd" runat="server" Text="添加" class="anniu" Width="73" Height="27"
                                                OnClick="btnadd_Click" OnClientClick="return submitForm()" />
                                        </td>
                                        <td height="20">
                                            &nbsp;
                                        </td>
                                        <td height="20">
                                            &nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="1">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>教育局账号管理</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <!-- 创建数据列表控件 -->
                                <table id="dg">
                                </table>
                                <div style="margin-top: 10px;">
                                </div>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td align="left">
                                            <input type="button" name="button2" id="button2" value="删除" class="anniu" width="73px"
                                                height="23px" onclick="DelSchoolAccList();" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
